public class Node(){
    public int value;
    public Node left;
    public Node right;

    public void Node(int data){
        this.value=data;
    }
}


public void preorder(Node head){
    if(head==null){
        return;
    }
    Stack<Node> stack=new Stack<>();
    stack.push(head);
    while(!head.isEmpty()){
        stack.pop();
        System.out.print(head.value+",");

        if(head.right!==null){
            stack.push(head.right);
        }
        if(head.left!==null){
            stack.push(head.left);
        }

    }

}